/**
 * Test Class - OrdersTests.
 * Boundary Conditions (Low, Middle, High, Null, 
 * Empty, Valid, Correct, Duplicates and more).
 * Tests use methods such as assertEquals, assertTrue, assertFalse.
 * 
 * @author ct267, msm41, sg350.
 */
package tests;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.util.TreeSet;
import restaurant.IOsystem;
import restaurant.MenuItem;
import restaurant.Orders;

public class OrdersTests {

	/** Test environment variables **/
	private TreeSet<MenuItem> menuTreeSet = null;
	private IOsystem io;
	private Orders orders;
	
	/** Setup environment model before running tests **/
	@Before
	public void setUp() {
		io = new IOsystem();
		menuTreeSet = io.readMenuFile("menu_input.txt");
		orders = new Orders(menuTreeSet);
	}

	/** Shutdown environment model and clean up resources **/
	@After
	public void tearDown() {
		menuTreeSet.clear();
		io = null;
		orders = null;
	}

	@Test
	public void getDiscount1() {
		// Zero value.
		double value = 0.00;
		String[] discountArr = orders.getDiscount(value);
		String title = discountArr[0];
		String discount = discountArr[1];

		assertEquals("N/A", title);
		assertEquals("0", discount);
	}

	@Test
	public void getDiscount2() {
		// Negative value.
		double value = -10.42;
		String[] discountArr = orders.getDiscount(value);
		String title = discountArr[0];
		String discount = discountArr[1];

		assertEquals("N/A", title);
		assertEquals("0", discount);
	}

	@Test
	public void getDiscount3() {
		// £0.00..£10 low boundary.
		double value = 0.01;
		String[] discountArr = orders.getDiscount(value);
		String title = discountArr[0];
		String discount = discountArr[1];

		assertEquals("N/A", title);
		assertEquals("0", discount);
	}

	@Test
	public void getDiscount4() {
		// £0.00..£10 high boundary.
		double value = 9.99;
		String[] discountArr = orders.getDiscount(value);
		String title = discountArr[0];
		String discount = discountArr[1];

		assertEquals("N/A", title);
		assertEquals("0", discount);
	}

	@Test
	public void getDiscount5() {
		// £10..£20 boundary.
		double value = 10.00;
		String[] discountArr = orders.getDiscount(value);
		String title = discountArr[0];
		String discount = discountArr[1];

		assertEquals("10% Applied!", title);
		assertEquals("1.0", discount);
	}

	@Test
	public void getDiscount6() {
		// £10..£20 low boundary.
		double value = 10.01;
		String[] discountArr = orders.getDiscount(value);
		String title = discountArr[0];
		// String discount = discountArr[1];

		assertEquals("10% Applied!", title);
		// assertEquals("1.00", discount);
	}

	@Test
	public void getDiscount7() {
		// £10..£20 high boundary.
		double value = 19.99;
		String[] discountArr = orders.getDiscount(value);
		String title = discountArr[0];
		// String discount = discountArr[1];

		assertEquals("10% Applied!", title);
		// assertEquals("1.0", discount);
	}

	@Test
	public void getDiscount8() {
		// £20..£30 boundary.
		double value = 20.00;
		String[] discountArr = orders.getDiscount(value);
		String title = discountArr[0];
		String discount = discountArr[1];

		assertEquals("20% Applied!", title);
		assertEquals("4.0", discount);
	}

	@Test
	public void getDiscount9() {
		// £20..£30 low boundary.
		double value = 20.01;
		String[] discountArr = orders.getDiscount(value);
		String title = discountArr[0];
		// String discount = discountArr[1];

		assertEquals("20% Applied!", title);
		// assertEquals("4.0", discount);
	}

	@Test
	public void getDiscount10() {
		// £20..£30 high boundary.
		double value = 29.99;
		String[] discountArr = orders.getDiscount(value);
		String title = discountArr[0];
		// String discount = discountArr[1];

		assertEquals("20% Applied!", title);
		// assertEquals("4.0", discount);
	}

	@Test
	public void getDiscount11() {
		// £30+ upper boundary.
		double value = 30.00;
		String[] discountArr = orders.getDiscount(value);
		String title = discountArr[0];
		String discount = discountArr[1];

		assertEquals("25% Applied!", title);
		assertEquals("7.5", discount);
	}
	
}
